//
//  DanXiangDieaseViewController.m
//  MyYiJianKangApp
//
//  Created by 张国文 on 16/5/6.
//  Copyright © 2016年 hangzhouyijiyin. All rights reserved.
//

#import "DanXiangDieaseViewController.h"
#import "MCBarChartView.h"
#import "XYPieChart.h"
#import "KWFormView.h"
#import "JiYinJianCeJieGuoModel.h"
#import "WenXianCanKaoListViewController.h"
#import "ZGWBiaoGeXiangJieViewController.h"
#import "ZGWJiBingFengXianJiuZhengViewController.h"

@interface DanXiangDieaseViewController ()<MCBarChartViewDataSource, MCBarChartViewDelegate, XYPieChartDataSource, KWFormViewDataSource, KWFormViewDelegate>

@property (nonatomic, strong) UIScrollView *backGroundScrollview; // 背景滚动图

@property (nonatomic, strong) MCBarChartView *myZhuZhuangView;  // 柱状图

@property (nonatomic, strong) NSMutableArray *huanBingGaiLv; // 患病概率数组

@property (nonatomic, strong) XYPieChart *myBingZhuangView; // 饼状图

@property (nonatomic, strong) KWFormView *jiYinBiaoGe; // 基因表

@property (nonatomic, strong) NSMutableArray *jiYinBiaoGeArray; // 基因表数组

@property (nonatomic, strong) NSMutableArray *xiaoLianRectArray; // 笑脸位置

@property (nonatomic, strong) KWFormView *ranSeTiBiaoGe; // 染色体表格

@property (nonatomic, strong) NSMutableArray *ranSeTiImageWeiZhiArray; // 保存染色体位置

@property (nonatomic, strong) NSMutableArray *ranSeTiNameArray; // 染色体名字

@property (nonatomic, strong) NSMutableArray *qiTaZhiBingYinSuArray; // 其他致病因素数组

@property (nonatomic, strong) NSMutableArray *jianKangJianYiArray; // 健康建议的数组

@property (nonatomic, strong) MCBarChartView *jiuZhengFengXianZhiView; // 就正如风险值柱状图

@property (nonatomic, strong) NSMutableArray *jiuZhengZhiArray; // 纠正值数组

@property (nonatomic, assign) CGFloat jiuZhengFengXianJieShaoBottom; // 纠正风险值介绍底部

@end

@implementation DanXiangDieaseViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.view.backgroundColor = [UIColor whiteColor];
    // navi的修改
    [self changeNavigation];
    // 添加数据源
    [self addData];
    // 布局
    [self addMySubview];
    
    [self addGongGao];
}

#pragma mark - 公告
- (void)addGongGao
{
   
    UIAlertController *alertVC = [UIAlertController alertControllerWithTitle:@"" message:@"我们以冠心病为例子进行展示，因此点击进入的所有单项都会跳转到该界面" preferredStyle:UIAlertControllerStyleAlert];
    // 修改message
    NSMutableAttributedString *messageString = [[NSMutableAttributedString alloc] initWithString:@"我们以冠心病为例子进行展示，因此点击进入的所有单项都会跳转到该界面"];
    [messageString addAttribute:NSForegroundColorAttributeName value:[UIColor blackColor] range:NSMakeRange(0, messageString.length)];
    [messageString addAttribute:NSFontAttributeName value:[UIFont systemFontOfSize:k17Big] range:NSMakeRange(0, messageString.length)];
    [alertVC setValue:messageString forKey:@"attributedMessage"];
    [self presentViewController:alertVC animated:YES completion:nil];
    dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(3 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
        [self dismissViewControllerAnimated:YES completion:nil];
    });
}

// 添加数据源
- (void)addData
{
    // 患病概率
    self.huanBingGaiLv = [NSMutableArray arrayWithObjects:@"2", @"3.6", nil];
    self.jiuZhengZhiArray = [NSMutableArray arrayWithObjects:@"2", @"4", nil];
    // 基因表数组
    NSMutableArray *jiYinArray = [NSMutableArray arrayWithObjects:@{@"geneName":@"eNOS", @"jianCeWeiDian":@"rs1800770", @"geneXing":@"GG", @"influence":@"促进", @"canKaoWenXian":@"1、2", @"gaiLue":@"10.00%"}, @{@"geneName":@"CELSAM", @"jianCeWeiDian":@"rs1800773", @"geneXing":@"GS", @"influence":@"平常", @"canKaoWenXian":@"1、2、3", @"gaiLue":@"20.00%"}, @{@"geneName":@"CYSABSXK", @"jianCeWeiDian":@"rs1800777", @"geneXing":@"SS", @"influence":@"抑制", @"canKaoWenXian":@"2、3", @"gaiLue":@"30.00%"}, nil];
    self.jiYinBiaoGeArray = [NSMutableArray array];
    for (NSDictionary *tempDic in jiYinArray) {
        JiYinJianCeJieGuoModel *model = [[JiYinJianCeJieGuoModel alloc] init];
        [model setValuesForKeysWithDictionary:tempDic];
        [self.jiYinBiaoGeArray addObject:model];
    }
    
    // 保存表格详解笑脸位置
    self.xiaoLianRectArray = [NSMutableArray array];
    for (int i = 0; i < self.jiYinBiaoGeArray.count; i++) {
  
        CGFloat tempCount = 30  * kAdjustParamater + 37 * i * kAdjustParamater;
        [self.xiaoLianRectArray addObject:[NSNumber numberWithFloat:tempCount]];
    }
    
    // 染色体名字数组
    self.ranSeTiNameArray = [NSMutableArray arrayWithObjects:@"染色体3-示例报告", @"染色体2-示例报告", @"染色体1-示例报告", nil];
    // 染色体位置
    self.ranSeTiImageWeiZhiArray = [NSMutableArray array];
    for (int i = 0; i < self.jiYinBiaoGeArray.count; i++) {
      //  [self.ranSeTiNameArray addObject:@"ranseti-shilibaogao"];
        CGFloat tempHeight = 25 * kAdjustParamater + 38 * i * kAdjustParamater;
        [self.ranSeTiImageWeiZhiArray addObject:[NSNumber numberWithFloat:tempHeight]];
    }
    
    
    // 其他致病因素数组
  //  self.qiTaZhiBingYinSuArray = [NSMutableArray arrayWithObjects:@"1、高血压可以提高患病风险盎司偶见佛in为偶奇偶就走", @"2、抽烟可以提高患病风险", @"3、喝酒可以提高患病风险", @"4、心脏病、心血管疾病可以提高患病风险", nil];
    self.qiTaZhiBingYinSuArray = [NSMutableArray arrayWithObjects:@"1、遗传因素 ：家族遗传倾向是冠心病的一个不可控危险因素。冠心病虽不像其他遗传病那样具有显而易见的遗传性，但它却有明显的遗传倾向。对于具有明显遗传倾向的人群在暴露同等时间，同等程度的其他危险因素时，这些人群更容易患冠心病。研究发现有冠心病家族史的人群较无冠心病家族史的人群发生冠心病的危险性增加2.0—3.9倍，发生心肌梗塞的危险性增加2.2倍，而且冠心病的发生较无冠心病家族史的人群提前数年，冠脉病变的程度也更重。冠心病在有家族史的人群发生率高可能是基因作用其他危险因素的结果。", @"2、可改变的危险因素有：高血压，血脂异常（总胆固醇过高或低密度脂蛋白胆固醇过高、甘油三酯过高、高密度脂蛋白胆固醇过低）、超重/肥胖、高血糖/糖尿病，不良生活方式包括吸烟、不合理膳食（高脂肪、高胆固醇、高热量等）、缺少体力活动、过量饮酒，以及社会心理因素。", @"3、不可改变的危险因素有：性别、年龄、家族史。此外，与感染有关，如巨细胞病毒、肺炎衣原体、幽门螺杆菌等。冠心病的发作常常与季节变化、情绪激动、体力活动增加、饱食、大量吸烟和饮酒等有关。", nil];
    // 健康建议数组
 //   self.jianKangJianYiArray = [NSMutableArray arrayWithObjects:@"积极进行体育锻炼，提高机体整体抗病能力，提升自身对疾病的免疫能力", @"注意加强营养", @"注意防范风寒", @"少吃辛辣食物、少喝酒", nil];
    self.jianKangJianYiArray = [NSMutableArray arrayWithObjects:@"生活习惯改变：戒烟限酒，低脂低盐饮食，适当体育锻炼，控制体重等；", @"药物治疗：抗血栓（抗血小板、抗凝），减轻心肌氧耗（β受体阻滞剂），缓解心绞痛（硝酸酯类），调脂稳定斑块（他汀类调脂药）；", @"血运重建治疗：包括介入治疗（血管内球囊扩张成形术和支架植入术）和外科冠状动脉旁路移植术；", nil];
    
}

// navi的修改
- (void)changeNavigation
{
    self.navigationItem.title = @"示例报告";
    UIImageView *leftImageView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 30, 30)];
    leftImageView.image = [UIImage imageNamed:@"houtui"];
    self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:leftImageView];
    UITapGestureRecognizer *leftTapGes = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(lastPage:)];
    [leftImageView addGestureRecognizer:leftTapGes];
    
}

#pragma mark - 返回上一页面
- (void)lastPage:(UITapGestureRecognizer *)tapGes
{
    [self.navigationController popViewControllerAnimated:YES];
}

- (void)addMySubview
{
    // 背景
    self.backGroundScrollview = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 0, kScreenWidth, kScreenHeight)];
    self.backGroundScrollview.backgroundColor = [UIColor whiteColor];
    self.backGroundScrollview.contentSize = CGSizeMake(kScreenWidth, 3 * kScreenHeight);
    self.backGroundScrollview.bounces = NO;
    [self.view addSubview:_backGroundScrollview];
    
    // 疾病介绍标题label
    UILabel *diseaseIntroduceTitleLabel = [[UILabel alloc] initWithFrame:CGRectMake(0 * kAdjustParamater, 15 * kAdjustParamater, 375 * kAdjustParamater, 20 * kAdjustParamater)];
   // diseaseIntroduceTitleLabel.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.1];
    diseaseIntroduceTitleLabel.text = @"疾病介绍";
    diseaseIntroduceTitleLabel.textColor = kCyanColor;
    diseaseIntroduceTitleLabel.textAlignment = NSTextAlignmentCenter;
    diseaseIntroduceTitleLabel.font = [UIFont fontWithName:@"Arial-BoldMT" size:k20Big];
    [self.backGroundScrollview addSubview:diseaseIntroduceTitleLabel];
    
    // 疾病介绍下方灰色条
    UILabel *grayLineOnDiseaseIntroduceBottom = [[UILabel alloc] initWithFrame:CGRectMake(0, diseaseIntroduceTitleLabel.bottom + 15 * kAdjustParamater, kScreenWidth, 1 * kAdjustParamater)];
    grayLineOnDiseaseIntroduceBottom.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.07];
    [self.backGroundScrollview addSubview:grayLineOnDiseaseIntroduceBottom];
    
    // 疾病介绍下方灰色条上方的倩色条
    UILabel *cyanLineOnDiseaseIntroduceBottom = [[UILabel alloc] initWithFrame:CGRectMake(275 / 2 * kAdjustParamater, diseaseIntroduceTitleLabel.bottom + 15 * kAdjustParamater, 100 * kAdjustParamater, 1 * kAdjustParamater)];
    cyanLineOnDiseaseIntroduceBottom.backgroundColor = kCyanColor;
    [self.backGroundScrollview addSubview:cyanLineOnDiseaseIntroduceBottom];
    
    // 疾病介绍
    UILabel *diseaseIntroduceLabel = [[UILabel alloc] initWithFrame:CGRectMake(11 * kAdjustParamater, grayLineOnDiseaseIntroduceBottom.bottom + 15 * kAdjustParamater, (375 - 22) * kAdjustParamater, 50 * kAdjustParamater)];
  //  diseaseIntroduceLabel.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.1];
    diseaseIntroduceLabel.text = @"     冠心病，古称胸痹，是一种最常见的心脏病，是指因冠状动脉狭窄、供血不足而引起的心肌机能障碍和(或)器质性病变，故又称缺血性心脏病(IHD)。症状表现胸腔中央发生一种压榨性的疼痛，并可迁延至颈、颔、手臂、后背及胃部。发作的其他可能症状有眩晕、气促、出汗、寒颤、恶心及昏厥。严重患者可能因为心力衰竭而死亡。";
    diseaseIntroduceLabel.textColor = [UIColor blackColor];
    diseaseIntroduceLabel.font = [UIFont systemFontOfSize:k15Big];
    diseaseIntroduceLabel.numberOfLines = 0;
    // 调整行间距
    [diseaseIntroduceLabel setAttributedText:[[NetStatusHandle shareHandle] setHangJianJvOfLabel:diseaseIntroduceLabel.text lineHeight:5]];
    [diseaseIntroduceLabel sizeToFit];
    [self.backGroundScrollview addSubview:diseaseIntroduceLabel];
    
    // 柱子
    self.myZhuZhuangView = [[MCBarChartView alloc] initWithFrame:CGRectMake(-10 * kAdjustParamater, diseaseIntroduceLabel.bottom + 10 * kAdjustParamater, 210 * kAdjustParamater, 180 * kAdjustParamater)];
   // self.myZhuZhuangView.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.1];
    self.myZhuZhuangView.dataSource  = self;
    self.myZhuZhuangView.delegate = self;
    self.myZhuZhuangView.tag = 400;
    self.myZhuZhuangView.maxValue = @"20";
    [self.backGroundScrollview addSubview:_myZhuZhuangView];
    
    // 饼状图
 //   self.myBingZhuangView = [[XYPieChart alloc] initWithFrame:CGRectMake(self.myZhuZhuangView.right + 10 * kAdjustParamater, self.myZhuZhuangView.top, 100 * kAdjustParamater, 100 * kAdjustParamater) Center:CGPointMake(self.myZhuZhuangView.right + 70 * kAdjustParamater, self.myZhuZhuangView.top + 70 * kAdjustParamater) Radius:50];
    self.myBingZhuangView = [[XYPieChart alloc] init];
    self.myBingZhuangView.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.1];
    self.myBingZhuangView.startPieAngle = M_PI_4 * 6;
    self.myBingZhuangView.animationSpeed = 0.1;
    self.myBingZhuangView.pieRadius = 40 * kAdjustParamater;
    self.myBingZhuangView.labelRadius = 53 * kAdjustParamater;
    self.myBingZhuangView.showLabel = YES;
    self.myBingZhuangView.showPercentage = NO;
    self.myBingZhuangView.pieCenter = CGPointMake(self.myZhuZhuangView.right + 60 * kAdjustParamater, self.myZhuZhuangView.top + 100 * kAdjustParamater);
    self.myBingZhuangView.labelFont = [UIFont systemFontOfSize:k17Big];
    
    
//    self.myBingZhuangView.pieCenter = CGPointMake(self.myZhuZhuangView.right + 70 * kAdjustParamater, self.myZhuZhuangView.top + 70 * kAdjustParamater);
//    self.myBingZhuangView.showPercentage = NO;
//    [self.myBingZhuangView setPieBackgroundColor:[UIColor whiteColor]];
    
//    self.myBingZhuangView.pieCenter = CGPointMake(self.myZhuZhuangView.right + 70 * kAdjustParamater, self.myZhuZhuangView.top + 70 * kAdjustParamater);
//    self.myBingZhuangView.pieRadius = 50 * kAdjustParamater;
    
    self.myBingZhuangView.dataSource = self;
    [self.myBingZhuangView reloadData];
    [self.backGroundScrollview addSubview:_myBingZhuangView];
    
    // 10W人患病概率
    UILabel *shiWanPeopleLabel = [[UILabel alloc] initWithFrame:CGRectMake(self.myZhuZhuangView.right, self.myZhuZhuangView.top + 10 * kAdjustParamater, 150 * kAdjustParamater, 15 * kAdjustParamater)];
 //   shiWanPeopleLabel.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.1];
    shiWanPeopleLabel.text = @"10万人患病人数";
    shiWanPeopleLabel.font = [UIFont systemFontOfSize:k15Big];
    [self.backGroundScrollview addSubview:shiWanPeopleLabel];
    
    UILabel *shiWanPeopleHuanBingCountLabel = [[UILabel alloc] initWithFrame:CGRectMake(shiWanPeopleLabel.left + 20 * kAdjustParamater, shiWanPeopleLabel.bottom + 20 * kAdjustParamater, 90 * kAdjustParamater, 10 * kAdjustParamater)];
    shiWanPeopleHuanBingCountLabel.font = [UIFont systemFontOfSize:k15Big];
    shiWanPeopleHuanBingCountLabel.textAlignment = NSTextAlignmentLeft;
    shiWanPeopleHuanBingCountLabel.text = [NSString stringWithFormat:@"%.0f人患病", [self.huanBingGaiLv.firstObject floatValue] * 100000 / 100];
    [self.backGroundScrollview addSubview:shiWanPeopleHuanBingCountLabel];
    // 正常图片
    UILabel *zhengChangImageV = [[UILabel alloc] initWithFrame:CGRectMake(self.myZhuZhuangView.right + 115 * kAdjustParamater, self.myZhuZhuangView.top + 95 * kAdjustParamater, 15 * kAdjustParamater, 15 * kAdjustParamater)];
    zhengChangImageV.backgroundColor = [UIColor colorWithRed:122 / 255.0 green:7 / 255.0 blue:84 / 255.0 alpha:1];
    zhengChangImageV.layer.cornerRadius = 3 * kAdjustParamater;
    zhengChangImageV.layer.masksToBounds = YES;
    [self.backGroundScrollview addSubview:zhengChangImageV];
    
    // 正常标题
    UILabel *zhengChangTitleLabel = [[UILabel alloc] initWithFrame:CGRectMake(zhengChangImageV.right + 10 * kAdjustParamater, zhengChangImageV.top, 50 * kAdjustParamater, 15 * kAdjustParamater)];
 //   zhengChangTitleLabel.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.1];
    zhengChangTitleLabel.text = @"正常";
    zhengChangTitleLabel.textColor = [UIColor blackColor];
    zhengChangTitleLabel.textAlignment = NSTextAlignmentLeft;
    zhengChangTitleLabel.font = [UIFont systemFontOfSize:k14Big];
    [self.backGroundScrollview addSubview:zhengChangTitleLabel];
    
    // 患病图片
    UILabel *huanBingImageV = [[UILabel alloc] initWithFrame:CGRectMake(zhengChangImageV.left, zhengChangImageV.bottom + 15 * kAdjustParamater, 15 * kAdjustParamater, 15 * kAdjustParamater)];
    huanBingImageV.backgroundColor = [UIColor colorWithRed:111 / 255.0 green:113 / 255.0 blue:179 / 255.0 alpha:1];
    huanBingImageV.layer.cornerRadius = 3 * kAdjustParamater;
    huanBingImageV.layer.masksToBounds = YES;
    [self.backGroundScrollview addSubview:huanBingImageV];
    
    // 患病标题
    UILabel *huanBingTitleLabel = [[UILabel alloc] initWithFrame:CGRectMake(huanBingImageV.right + 10 * kAdjustParamater, huanBingImageV.top, 50 * kAdjustParamater, 15 * kAdjustParamater)];
 //   huanBingTitleLabel.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.1];
    huanBingTitleLabel.text = @"患病";
    huanBingTitleLabel.textColor = [UIColor blackColor];
    huanBingTitleLabel.textAlignment = NSTextAlignmentLeft;
    huanBingTitleLabel.font = [UIFont systemFontOfSize:k14Big];
    [self.backGroundScrollview addSubview:huanBingTitleLabel];
    
    // 患病率柱子下方的灰色条
    UILabel *grayLineOnHuanBingLvZhuZiBottom = [[UILabel alloc] initWithFrame:CGRectMake(0, self.myZhuZhuangView.bottom + 30 * kAdjustParamater, kScreenWidth, 10 * kAdjustParamater)];
    grayLineOnHuanBingLvZhuZiBottom.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.05];
    [self.backGroundScrollview addSubview:grayLineOnHuanBingLvZhuZiBottom];
    
    // 检测结果
    UILabel *jianCeJieGuoLabel = [[UILabel alloc] initWithFrame:CGRectMake(0 * kAdjustParamater, grayLineOnHuanBingLvZhuZiBottom.bottom + 15 * kAdjustParamater, 375 * kAdjustParamater, 20 * kAdjustParamater)];
    // diseaseIntroduceTitleLabel.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.1];
    jianCeJieGuoLabel.text = @"检测结果";
    jianCeJieGuoLabel.textColor = kCyanColor;
    jianCeJieGuoLabel.textAlignment = NSTextAlignmentCenter;
    jianCeJieGuoLabel.font = [UIFont fontWithName:@"Arial-BoldMT" size:k20Big];
    [self.backGroundScrollview addSubview:jianCeJieGuoLabel];
    
    // 检测结果下方灰色条
    UILabel *grayLineOnJianCeJieGuoBottom = [[UILabel alloc] initWithFrame:CGRectMake(0, jianCeJieGuoLabel.bottom + 15 * kAdjustParamater, kScreenWidth, 1 * kAdjustParamater)];
    grayLineOnJianCeJieGuoBottom.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.07];
    [self.backGroundScrollview addSubview:grayLineOnJianCeJieGuoBottom];
    
    // 检测结果下方灰色条上方的倩色条
    UILabel *cyanLineOnJianCeJieGuoBottom = [[UILabel alloc] initWithFrame:CGRectMake(275 / 2 * kAdjustParamater, jianCeJieGuoLabel.bottom + 15 * kAdjustParamater, 100 * kAdjustParamater, 1 * kAdjustParamater)];
    cyanLineOnJianCeJieGuoBottom.backgroundColor = kCyanColor;
    [self.backGroundScrollview addSubview:cyanLineOnJianCeJieGuoBottom];
    
#warning 基因表
    self.jiYinBiaoGe = [[KWFormView alloc] initWithFrame:CGRectMake(13  *kAdjustParamater,  grayLineOnJianCeJieGuoBottom.bottom + 20 * kAdjustParamater, 340 * kAdjustParamater, (22 + 38 * self.jiYinBiaoGeArray.count) * kAdjustParamater)];
    self.jiYinBiaoGe.dataSource = self;
    self.jiYinBiaoGe.delegate = self;
    self.jiYinBiaoGe.tag = 300;
    [self.backGroundScrollview addSubview:_jiYinBiaoGe];
    
   
    for (int i = 0; i < self.jiYinBiaoGeArray.count; i++) {
        JiYinJianCeJieGuoModel *tempModel = self.jiYinBiaoGeArray[i];
        NSString *influenceString = [tempModel valueForKey:@"influence"];
        // 位置
        CGFloat heightWeiZhi = [self.xiaoLianRectArray[i] floatValue];
         UIImageView *tempImageV = [[UIImageView alloc] initWithFrame:CGRectMake(230 * kAdjustParamater, heightWeiZhi * kAdjustParamater, 25 * kAdjustParamater, 25 * kAdjustParamater)];
     //   tempImageV.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.1];
        if ([influenceString isEqualToString:@"促进"]) {
            tempImageV.image = [UIImage imageNamed:@"weixiao-shili"];
        } else if ([influenceString isEqualToString:@"平常"]) {
            tempImageV.image = [UIImage imageNamed:@"zhengchang-shili"];
        } else if ([influenceString isEqualToString:@"抑制"]) {
            tempImageV.image = [UIImage imageNamed:@"ku-shili"];
        }
        [_jiYinBiaoGe addSubview:tempImageV];
    }
   
    // 表格详解
    UIButton *biaoGeXiangJieButton = [UIButton buttonWithType:UIButtonTypeSystem];
    biaoGeXiangJieButton.frame = CGRectMake(95 / 2 * kAdjustParamater,self.jiYinBiaoGe.bottom + 30 * kAdjustParamater, 115 * kAdjustParamater, 30 * kAdjustParamater);
    biaoGeXiangJieButton.backgroundColor = kCyanColor;
    [biaoGeXiangJieButton setTitle:@"表格详解" forState:UIControlStateNormal];
    [biaoGeXiangJieButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    biaoGeXiangJieButton.layer.cornerRadius = 5 * kAdjustParamater;
    biaoGeXiangJieButton.titleLabel.font = [UIFont fontWithName:@"Arial-BoldMT" size:k18Big];
    [biaoGeXiangJieButton addTarget:self action:@selector(biaoGeXiangJie:) forControlEvents:UIControlEventTouchUpInside];
    [self.backGroundScrollview addSubview:biaoGeXiangJieButton];
    
    // 参考文献
    UIButton *canKaoWenXianButton = [UIButton buttonWithType:UIButtonTypeSystem];
    canKaoWenXianButton.frame = CGRectMake(biaoGeXiangJieButton.right + 50 * kAdjustParamater, biaoGeXiangJieButton.top, 115 * kAdjustParamater, 30 * kAdjustParamater);
    canKaoWenXianButton.backgroundColor = kCyanColor;
    [canKaoWenXianButton setTitle:@"参考文献" forState:UIControlStateNormal];
    [canKaoWenXianButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    canKaoWenXianButton.layer.cornerRadius = 5 * kAdjustParamater;
    canKaoWenXianButton.titleLabel.font = [UIFont fontWithName:@"Arial-BoldMT" size:k18Big];
    [canKaoWenXianButton addTarget:self action:@selector(canKaoWenXian:) forControlEvents:UIControlEventTouchUpInside];
    [self.backGroundScrollview addSubview:canKaoWenXianButton];
    
    // 表格详解下方的灰色条
    UILabel *grayLineOnBiaoGeXiangJieBottom = [[UILabel alloc] initWithFrame:CGRectMake(0, biaoGeXiangJieButton.bottom + 20 * kAdjustParamater, kScreenWidth, 10 * kAdjustParamater)];
    grayLineOnBiaoGeXiangJieBottom.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.05];
    [self.backGroundScrollview addSubview:grayLineOnBiaoGeXiangJieBottom];

    // 基因位置标题label
    UILabel *jiYinWeiZhiLabel = [[UILabel alloc] initWithFrame:CGRectMake(0 * kAdjustParamater,grayLineOnBiaoGeXiangJieBottom.bottom + 15 * kAdjustParamater, 375 * kAdjustParamater, 20 * kAdjustParamater)];
    // diseaseIntroduceTitleLabel.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.1];
    jiYinWeiZhiLabel.text = @"基因位置";
    jiYinWeiZhiLabel.textColor = kCyanColor;
    jiYinWeiZhiLabel.textAlignment = NSTextAlignmentCenter;
    jiYinWeiZhiLabel.font = [UIFont fontWithName:@"Arial-BoldMT" size:k20Big];
    [self.backGroundScrollview addSubview:jiYinWeiZhiLabel];
    
    // 基因位置下方灰色条
    UILabel *grayLineOnJiYinWeiZhiBottom = [[UILabel alloc] initWithFrame:CGRectMake(0, jiYinWeiZhiLabel.bottom + 15 * kAdjustParamater, kScreenWidth, 1 * kAdjustParamater)];
    grayLineOnJiYinWeiZhiBottom.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.07];
    [self.backGroundScrollview addSubview:grayLineOnJiYinWeiZhiBottom];
    
    // 基因位置下方灰色条上方的倩色条
    UILabel *cyanLineOnJiYinWeiZhiBottom = [[UILabel alloc] initWithFrame:CGRectMake(275 / 2 * kAdjustParamater, jiYinWeiZhiLabel.bottom + 15 * kAdjustParamater, 100 * kAdjustParamater, 1 * kAdjustParamater)];
    cyanLineOnJiYinWeiZhiBottom.backgroundColor = kCyanColor;
    [self.backGroundScrollview addSubview:cyanLineOnJiYinWeiZhiBottom];
    
#warning 染色体信息
    // 染色体信息背景
    UIView *ranSeTiBackGroundView = [[UIView alloc] initWithFrame:CGRectMake(10 * kAdjustParamater, grayLineOnJiYinWeiZhiBottom.bottom + 20 * kAdjustParamater, 355 * kAdjustParamater, 170 * kAdjustParamater)];
    ranSeTiBackGroundView.backgroundColor = kCyanColor;
    [self.backGroundScrollview addSubview:ranSeTiBackGroundView];
    
    // 染色体信息标题
    UILabel *ranSeTiTitleLabel = [[UILabel alloc] initWithFrame:CGRectMake(255 / 2 * kAdjustParamater, 5 * kAdjustParamater, 100 * kAdjustParamater, 17 * kAdjustParamater)];
 //   ranSeTiTitleLabel.backgroundColor = [[UIColor redColor] colorWithAlphaComponent:0.1];
    ranSeTiTitleLabel.text = @"染色体信息";
    ranSeTiTitleLabel.textColor = [UIColor whiteColor];
    ranSeTiTitleLabel.textAlignment = NSTextAlignmentCenter;
    ranSeTiTitleLabel.font = [UIFont fontWithName:@"Arial-BoldMT" size:k17Big];
    [ranSeTiBackGroundView addSubview:ranSeTiTitleLabel];
    
    // 染色体表格
    self.ranSeTiBiaoGe = [[KWFormView alloc] initWithFrame:CGRectMake(10 * kAdjustParamater, 27 * kAdjustParamater, 335 * kAdjustParamater, (22 + 38 * self.jiYinBiaoGeArray.count) * kAdjustParamater)];
    self.ranSeTiBiaoGe.dataSource = self;
    self.ranSeTiBiaoGe.delegate = self;
    self.ranSeTiBiaoGe.tag = 301;
    [ranSeTiBackGroundView addSubview:_ranSeTiBiaoGe];
    // 重新布局染色体背景的大小
    ranSeTiBackGroundView.frame = CGRectMake(ranSeTiBackGroundView.frame.origin.x, ranSeTiBackGroundView.frame.origin.y, ranSeTiBackGroundView.width, self.ranSeTiBiaoGe.height + 37 * kAdjustParamater);
    // 添加染色体图片
    for (int i = 0; i < self.ranSeTiImageWeiZhiArray.count; i++) {
        CGFloat ranSeTiHeight= [self.ranSeTiImageWeiZhiArray[i] floatValue];
        UIImageView *ranSeTiImageV = [[UIImageView alloc] initWithFrame:CGRectMake(115 * kAdjustParamater, ranSeTiHeight, 180 * kAdjustParamater, 33 * kAdjustParamater)];
        ranSeTiImageV.image = [UIImage imageNamed:self.ranSeTiNameArray[i]];
        [self.ranSeTiBiaoGe addSubview:ranSeTiImageV];
    }
    
    // 染色体表格下方的灰色条
    UILabel *grayLineOnRanSeTiBiaoGeBottom = [[UILabel alloc] initWithFrame:CGRectMake(0, ranSeTiBackGroundView.bottom + 20 * kAdjustParamater, kScreenWidth, 10 * kAdjustParamater)];
    grayLineOnRanSeTiBiaoGeBottom.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.05];
    [self.backGroundScrollview addSubview:grayLineOnRanSeTiBiaoGeBottom];
    
    
    
#warning 其他致病因素
    // 其他致病因素背景
    
    
    UILabel *qiTaZhiBingYinSuLabel = [[UILabel alloc] initWithFrame:CGRectMake(0 * kAdjustParamater, grayLineOnRanSeTiBiaoGeBottom.bottom + 15 * kAdjustParamater, 375 * kAdjustParamater, 20 * kAdjustParamater)];
    // diseaseIntroduceTitleLabel.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.1];
    qiTaZhiBingYinSuLabel.text = @"其他致病因素";
    qiTaZhiBingYinSuLabel.textColor = kCyanColor;
    qiTaZhiBingYinSuLabel.textAlignment = NSTextAlignmentCenter;
    qiTaZhiBingYinSuLabel.font = [UIFont fontWithName:@"Arial-BoldMT" size:k20Big];
    [self.backGroundScrollview addSubview:qiTaZhiBingYinSuLabel];
    
    // 检测结果下方灰色条
    UILabel *grayLineOnqiTaZhiBingYinSuBottom = [[UILabel alloc] initWithFrame:CGRectMake(0, qiTaZhiBingYinSuLabel.bottom + 15 * kAdjustParamater, kScreenWidth, 1 * kAdjustParamater)];
    grayLineOnqiTaZhiBingYinSuBottom.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.07];
    [self.backGroundScrollview addSubview:grayLineOnqiTaZhiBingYinSuBottom];
    
    // 检测结果下方灰色条上方的倩色条
    UILabel *cyanLineOnqiTaZhiBingYinSuBottom = [[UILabel alloc] initWithFrame:CGRectMake(245 / 2 * kAdjustParamater, qiTaZhiBingYinSuLabel.bottom + 15 * kAdjustParamater, 130 * kAdjustParamater, 1 * kAdjustParamater)];
    cyanLineOnqiTaZhiBingYinSuBottom.backgroundColor = kCyanColor;
    [self.backGroundScrollview addSubview:cyanLineOnqiTaZhiBingYinSuBottom];
    
//    UIView *qiTaZhiBingYinBackGroundView = [[UIView alloc] initWithFrame:CGRectMake(0, ranSeTiBackGroundView.bottom + 15 * kAdjustParamater, kScreenWidth, 28 * kAdjustParamater)];
//    qiTaZhiBingYinBackGroundView.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.05];
//    [self.backGroundScrollview addSubview:qiTaZhiBingYinBackGroundView];
//    
//    // 其他致病因素标题
//    UILabel *qiTaZhiBingTitleLabel = [[UILabel alloc] initWithFrame:CGRectMake((375 - 150) / 2 * kAdjustParamater, 5 * kAdjustParamater, 150 * kAdjustParamater, 18 * kAdjustParamater)];
//    qiTaZhiBingTitleLabel.text = @"其他致病因素";
//    qiTaZhiBingTitleLabel.textColor = kCyanColor;
//    qiTaZhiBingTitleLabel.textAlignment = NSTextAlignmentCenter;
//    qiTaZhiBingTitleLabel.font = [UIFont fontWithName:@"Arial-BoldMT" size:k17Big];
//    [qiTaZhiBingYinBackGroundView addSubview:qiTaZhiBingTitleLabel];
    
    // 保存下一次的高度
    CGFloat zhiBingYuanYinNextHeight = 0.0;
    // 动态构建致病原因
    for (int i = 0; i < self.qiTaZhiBingYinSuArray.count; i++) {
        // 前方圆圈
        UIView *yuanQuanView = [[UIView alloc] initWithFrame:CGRectMake(18 * kAdjustParamater, 15 * kAdjustParamater + zhiBingYuanYinNextHeight + grayLineOnqiTaZhiBingYinSuBottom.bottom, 15 * kAdjustParamater, 15 * kAdjustParamater)];
        yuanQuanView.backgroundColor = kCyanColor;
        yuanQuanView.layer.cornerRadius = yuanQuanView.width / 2;
        yuanQuanView.layer.masksToBounds = YES;
        [self.backGroundScrollview addSubview:yuanQuanView];
        
        // 致病因素label
        UILabel *zhiBingYinSuLabel = [[UILabel alloc] initWithFrame:CGRectMake(yuanQuanView.right + 7 * kAdjustParamater, yuanQuanView.top - 2 * kAdjustParamater, 325 * kAdjustParamater, 10 * kAdjustParamater)];
   //     zhiBingYinSuLabel.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.1];
        zhiBingYinSuLabel.text = self.qiTaZhiBingYinSuArray[i];
        zhiBingYinSuLabel.textColor = [UIColor blackColor];
        zhiBingYinSuLabel.numberOfLines = 0;
        zhiBingYinSuLabel.tag = 500 + i;
        zhiBingYinSuLabel.font = [UIFont systemFontOfSize:k15Big];
        // 调整高度
        CGRect newZhiBingYinSuFrame = zhiBingYinSuLabel.frame;
        newZhiBingYinSuFrame.size.height = [[NetStatusHandle shareHandle] adjustHeight:zhiBingYinSuLabel.text size:15 width:325];
        zhiBingYinSuLabel.frame = newZhiBingYinSuFrame;
        zhiBingYuanYinNextHeight = zhiBingYuanYinNextHeight + zhiBingYinSuLabel.height + 10 * kAdjustParamater;
        [self.backGroundScrollview addSubview:zhiBingYinSuLabel];
    }
    // 取出最后一个label
    UILabel *lastLabel = (UILabel *)[self.view viewWithTag:499 + self.qiTaZhiBingYinSuArray.count];
    // 致病因素下面的灰色条
    UILabel *grayLineOnZhiBingYinSuBottom = [[UILabel alloc] initWithFrame:CGRectMake(0, lastLabel.bottom + 20 * kAdjustParamater, kScreenWidth, 10 * kAdjustParamater)];
    grayLineOnZhiBingYinSuBottom.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.05];
    [self.backGroundScrollview addSubview:grayLineOnZhiBingYinSuBottom];
    
    // 检测结果
    UILabel *huanBingFengXianZhiJiuZhengLabel = [[UILabel alloc] initWithFrame:CGRectMake(0 * kAdjustParamater, grayLineOnZhiBingYinSuBottom.bottom + 15 * kAdjustParamater, 375 * kAdjustParamater, 20 * kAdjustParamater)];
    // diseaseIntroduceTitleLabel.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.1];
    huanBingFengXianZhiJiuZhengLabel.text = @"患病风险纠正";
    huanBingFengXianZhiJiuZhengLabel.textColor = kCyanColor;
    huanBingFengXianZhiJiuZhengLabel.textAlignment = NSTextAlignmentCenter;
    huanBingFengXianZhiJiuZhengLabel.font = [UIFont fontWithName:@"Arial-BoldMT" size:k20Big];
    [self.backGroundScrollview addSubview:huanBingFengXianZhiJiuZhengLabel];
    
    // 检测结果下方灰色条
    UILabel *grayLineOnhuanBingFengXianZhiJiuZhengBottom = [[UILabel alloc] initWithFrame:CGRectMake(0, huanBingFengXianZhiJiuZhengLabel.bottom + 15 * kAdjustParamater, kScreenWidth, 1 * kAdjustParamater)];
    grayLineOnhuanBingFengXianZhiJiuZhengBottom.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.07];
    [self.backGroundScrollview addSubview:grayLineOnhuanBingFengXianZhiJiuZhengBottom];
    
    // 检测结果下方灰色条上方的倩色条
    UILabel *cyanLineOnhuanBingFengXianZhiJiuZhengBottom = [[UILabel alloc] initWithFrame:CGRectMake(245 / 2 * kAdjustParamater, huanBingFengXianZhiJiuZhengLabel.bottom + 15 * kAdjustParamater, 130 * kAdjustParamater, 1 * kAdjustParamater)];
    cyanLineOnhuanBingFengXianZhiJiuZhengBottom.backgroundColor = kCyanColor;
    [self.backGroundScrollview addSubview:cyanLineOnhuanBingFengXianZhiJiuZhengBottom];
    
    // 纠正风险值的介绍
    UILabel *jiZhengFengXianZhiJieShaoLabel = [[UILabel alloc] initWithFrame:CGRectMake(10 * kAdjustParamater, grayLineOnhuanBingFengXianZhiJiuZhengBottom.bottom + 20 * kAdjustParamater, 355 * kAdjustParamater, 50 * kAdjustParamater)];
//    jiZhengFengXianZhiJieShaoLabel.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.1];
    jiZhengFengXianZhiJieShaoLabel.text = @"     根据您下单时填写的个人信息，综合考虑后得出如下所示的信息。您可以点击右边“纠正风险值”按钮改变纠正后风险值。 ";
    jiZhengFengXianZhiJieShaoLabel.textColor = kCyanColor;
    jiZhengFengXianZhiJieShaoLabel.font = [UIFont fontWithName:@"Arial-BoldMT" size:k14Big];
    jiZhengFengXianZhiJieShaoLabel.numberOfLines = 0;
    [jiZhengFengXianZhiJieShaoLabel setAttributedText:[[NetStatusHandle shareHandle] setHangJianJvOfLabel:jiZhengFengXianZhiJieShaoLabel.text lineHeight:4]];
    [jiZhengFengXianZhiJieShaoLabel sizeToFit];
    [self.backGroundScrollview addSubview:jiZhengFengXianZhiJieShaoLabel];
    
    self.jiuZhengFengXianJieShaoBottom = jiZhengFengXianZhiJieShaoLabel.bottom;
    
//    // 纠正风险值柱状图
//    self.jiuZhengFengXianZhiView = [[MCBarChartView alloc] initWithFrame:CGRectMake(-10 * kAdjustParamater, jiZhengFengXianZhiJieShaoLabel.bottom + 5 * kAdjustParamater, 250 * kAdjustParamater, 200 * kAdjustParamater)];
//  //  self.jiuZhengFengXianZhiView.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.1];
//    self.jiuZhengFengXianZhiView.dataSource = self;
//    self.jiuZhengFengXianZhiView.delegate = self;
//    self.jiuZhengFengXianZhiView.tag = 401;
//    self.jiuZhengFengXianZhiView.maxValue = @"20";
//    [self.backGroundScrollview addSubview:_jiuZhengFengXianZhiView];
    // 添加纠正风险值柱状图
    [self addJiuZhengFengXianZhuZhuangView];
    // 纠正风险值
    UIButton *jiuZhengFengXianButton = [UIButton buttonWithType:UIButtonTypeSystem];
    jiuZhengFengXianButton.backgroundColor = [UIColor whiteColor];
    jiuZhengFengXianButton.frame = CGRectMake(240 * kAdjustParamater, jiZhengFengXianZhiJieShaoLabel.bottom + 50 * kAdjustParamater, 108 * kAdjustParamater, 30 * kAdjustParamater);
    [jiuZhengFengXianButton setTitle:@"风险值矫正" forState: UIControlStateNormal];
    [jiuZhengFengXianButton setTitleColor:kCyanColor forState:UIControlStateNormal];
    jiuZhengFengXianButton.titleLabel.font = [UIFont fontWithName:@"Arial-BoldMT" size:k17Big];
    jiuZhengFengXianButton.layer.cornerRadius = 5 * kAdjustParamater;
    jiuZhengFengXianButton.layer.borderWidth = 1 * kAdjustParamater;
    jiuZhengFengXianButton.layer.borderColor = [kCyanColor CGColor];
    [jiuZhengFengXianButton addTarget:self action:@selector(jiuZhengFengXianButton:) forControlEvents:UIControlEventTouchUpInside];
    [self.backGroundScrollview addSubview:jiuZhengFengXianButton];
    
    // 提示前方的图标
    UIImageView *warningImageV = [[UIImageView alloc] initWithFrame:CGRectMake(20 * kAdjustParamater, jiZhengFengXianZhiJieShaoLabel.bottom + 215 * kAdjustParamater, 25 * kAdjustParamater, 25 * kAdjustParamater)];
    warningImageV.image = [UIImage imageNamed:@"warning-shilibaogao"];
    [self.backGroundScrollview addSubview:warningImageV];
    
    // 提示的标题
    UILabel *warningTitleLabel = [[UILabel alloc] initWithFrame:CGRectMake(warningImageV.right + 4 * kAdjustParamater, warningImageV.top + 5 * kAdjustParamater, 320 * kAdjustParamater, 12 * kAdjustParamater)];
   // warningTitleLabel.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.1];
  //  warningTitleLabel.text = @"小提示：纠正值为将基因检测结果结合生活习惯和患病历史得出的风险评估值";
    warningTitleLabel.text = @"小提示：矫正后患病概率为将基因检测结果结合您的真实资料和个人生活习惯以及疾病史计算得来，更为真实可信。";
    warningTitleLabel.textColor = [UIColor redColor];
    warningTitleLabel.font = [UIFont systemFontOfSize:k12Big];
    warningTitleLabel.numberOfLines = 0;
    CGRect newFrameOfWarningTitleLabel = warningTitleLabel.frame;
    newFrameOfWarningTitleLabel.size.height = [[NetStatusHandle shareHandle] adjustHeight:warningTitleLabel.text size:12 width:320];
    warningTitleLabel.frame = newFrameOfWarningTitleLabel;
    [self.backGroundScrollview addSubview:warningTitleLabel];
    
    // 小提示下方的灰色条
    UILabel *grayLineOnXiaoTiShiBottom = [[UILabel alloc] initWithFrame:CGRectMake(0, warningTitleLabel.bottom + 20 * kAdjustParamater, kScreenWidth, 10 * kAdjustParamater)];
    grayLineOnXiaoTiShiBottom.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.05];
    [self.backGroundScrollview addSubview:grayLineOnXiaoTiShiBottom];
    
#warning 健康建议
    // 健康建议
    UILabel *jianKangJianYiLabel = [[UILabel alloc] initWithFrame:CGRectMake(0 * kAdjustParamater, grayLineOnXiaoTiShiBottom.bottom + 15 * kAdjustParamater, 375 * kAdjustParamater, 20 * kAdjustParamater)];
    // diseaseIntroduceTitleLabel.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.1];
    jianKangJianYiLabel.text = @"健康建议";
    jianKangJianYiLabel.textColor = kCyanColor;
    jianKangJianYiLabel.textAlignment = NSTextAlignmentCenter;
    jianKangJianYiLabel.font = [UIFont fontWithName:@"Arial-BoldMT" size:k20Big];
    [self.backGroundScrollview addSubview:jianKangJianYiLabel];
    
    // 健康建议下方灰色条
    UILabel *grayLineOnjianKangJianYiBottom = [[UILabel alloc] initWithFrame:CGRectMake(0, jianKangJianYiLabel.bottom + 15 * kAdjustParamater, kScreenWidth, 1 * kAdjustParamater)];
    grayLineOnjianKangJianYiBottom.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.07];
    [self.backGroundScrollview addSubview:grayLineOnjianKangJianYiBottom];
    
    // 健康建议下方灰色条上方的倩色条
    UILabel *cyanLineOnjianKangJianYiBottom = [[UILabel alloc] initWithFrame:CGRectMake(275 / 2 * kAdjustParamater, jianKangJianYiLabel.bottom + 15 * kAdjustParamater, 100 * kAdjustParamater, 1 * kAdjustParamater)];
    cyanLineOnjianKangJianYiBottom.backgroundColor = kCyanColor;
    [self.backGroundScrollview addSubview:cyanLineOnjianKangJianYiBottom];
    
//    // 健康建议的背景
//    UIView *jianKangJianYiBackgroundView = [[UIView alloc] initWithFrame:CGRectMake(0, warningTitleLabel.bottom + 15 * kAdjustParamater, kScreenWidth, 28 * kAdjustParamater)];
//    jianKangJianYiBackgroundView.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.05];
//    [self.backGroundScrollview addSubview:jianKangJianYiBackgroundView];
//    
//    // 健康建议标题
//    UILabel *jianKangJianTitleLabel = [[UILabel alloc] initWithFrame:CGRectMake((375 - 150) / 2 * kAdjustParamater, 5 * kAdjustParamater, 150 * kAdjustParamater, 18 * kAdjustParamater)];
//    jianKangJianTitleLabel.text = @"健康建议";
//    jianKangJianTitleLabel.textColor = kCyanColor;
//    jianKangJianTitleLabel.textAlignment = NSTextAlignmentCenter;
//    jianKangJianTitleLabel.font = [UIFont fontWithName:@"Arial-BoldMT" size:k17Big];
//    [jianKangJianYiBackgroundView addSubview:jianKangJianTitleLabel];
    
    // 进行健康建议的动态布局
    // 保存健康建议下一个开始位置
    CGFloat jianKangJianYiNextHeight = 0.0;
    for (int i = 0; i < self.jianKangJianYiArray.count; i++) {
        // 健康建议前方图标
        UILabel *jianKangJianYiImageV = [[UILabel alloc] initWithFrame:CGRectMake(18 * kAdjustParamater, grayLineOnjianKangJianYiBottom.bottom + 13 * kAdjustParamater + jianKangJianYiNextHeight, 42 * kAdjustParamater, 20 * kAdjustParamater)];
        jianKangJianYiImageV.backgroundColor = kCyanColor;
        jianKangJianYiImageV.text = [NSString stringWithFormat:@"NO.%d", i + 1];
        jianKangJianYiImageV.textColor = [UIColor whiteColor];
        jianKangJianYiImageV.textAlignment = NSTextAlignmentCenter;
        jianKangJianYiImageV.font = [UIFont fontWithName:@"Arial-BoldMT" size:k14Big];
        jianKangJianYiImageV.layer.cornerRadius = 5 * kAdjustParamater;
        jianKangJianYiImageV.layer.masksToBounds = YES;
        [self.backGroundScrollview addSubview:jianKangJianYiImageV];
        
        // 健康建议内容
        UILabel *jianKangJianYiContentLabel = [[UILabel alloc] initWithFrame:CGRectMake(jianKangJianYiImageV.right + 15 * kAdjustParamater, jianKangJianYiImageV.top + 1 * kAdjustParamater, 285 * kAdjustParamater, 10 * kAdjustParamater)];
    //    jianKangJianYiContentLabel.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.1];
        jianKangJianYiContentLabel.text = self.jianKangJianYiArray[i];
        jianKangJianYiContentLabel.textColor = [UIColor blackColor];
        jianKangJianYiContentLabel.numberOfLines = 0;
        jianKangJianYiContentLabel.font = [UIFont systemFontOfSize:k14Big];
        // 调整高度
        CGRect jianKangJianYiNewFrame = jianKangJianYiContentLabel.frame;
        jianKangJianYiNewFrame.size.height = [[NetStatusHandle shareHandle] adjustHeight:jianKangJianYiContentLabel.text size:14 width:285];
        jianKangJianYiContentLabel.frame = jianKangJianYiNewFrame;
        [self.backGroundScrollview addSubview:jianKangJianYiContentLabel];
        
        // 添加灰色条
        UILabel *grayLineOnJianKangJianYiContentBottom = [[UILabel alloc] initWithFrame:CGRectMake(0, jianKangJianYiContentLabel.bottom + 15 * kAdjustParamater, kScreenWidth, 1 * kAdjustParamater)];
        grayLineOnJianKangJianYiContentBottom.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.08];
        grayLineOnJianKangJianYiContentBottom.tag = 600 + i;
        [self.backGroundScrollview addSubview:grayLineOnJianKangJianYiContentBottom];
        jianKangJianYiNextHeight = jianKangJianYiNextHeight + jianKangJianYiContentLabel.height + 16 * kAdjustParamater + 13 * kAdjustParamater;
        
    }
    // 取出健康建议最后一个灰色条
    UILabel *lastGrayLineOfJianKangJianYi = (UILabel *)[self.view viewWithTag:599 + self.jianKangJianYiArray.count];
    // 重新对scrollView进行大小布局
    self.backGroundScrollview.contentSize = CGSizeMake(kScreenWidth, lastGrayLineOfJianKangJianYi.bottom + 50 * kAdjustParamater);
    
}

#pragma mark - 表格的代理
- (NSInteger)numberOfRowsInFormView:(KWFormView *)formView
{
    if (formView.tag == 300) {
        return 1 + self.jiYinBiaoGeArray.count;
    } else if (formView.tag == 301) {
        return 1 + self.jiYinBiaoGeArray.count;
    }
    return 0;
}

- (NSInteger)formViewColumnsInRow:(KWFormView *)formView
{
    if (formView.tag == 300) {
        return 7;
    } else if (formView.tag == 301) {
        return 2;
    }
    return 0;
}

- (CGFloat)formView:(KWFormView *)formView widthForColumn:(NSInteger)column
{
    if (formView.tag == 300) {
        if (column == 0) {
            return 58 * kAdjustParamater;
        } else if (column == 1) {
            return 65 * kAdjustParamater;
        } else if (column == 2) {
            return 46 * kAdjustParamater;
        } else if (column == 3) {
            return 59 * kAdjustParamater;
        } else if (column == 4) {
            return 28 * kAdjustParamater;
        } else if (column == 5) {
            return 43 * kAdjustParamater;
        } else if (column == 6) {
            return 46 * kAdjustParamater;
        }

    } else if (formView.tag == 301) {
        if (column == 0) {
            return 80 * kAdjustParamater;
        } else if (column == 1) {
            return 255 * kAdjustParamater;
        }
    }
    return 0;
}

- (NSString *)formView:(KWFormView *)formView textForColumn:(NSInteger)column inRow:(NSInteger)row
{
    if (formView.tag == 300) {
        if (row == 0) {
            if (column == 0) {
                return @"基因";
            } else if (column == 1) {
                return @"检测位点";
            } else if (column == 2) {
                return @"基因型";
            } else if (column == 3) {
                return @"基因型概率";
            } else if (column == 4) {
                return @"评价";
            } else if (column == 5) {
                return @"影响";
            } else if (column == 6) {
                return @"参考文献";
            }
        } else {
            // 获得model
            if (self.jiYinBiaoGeArray.count > (row - 1)) {
                JiYinJianCeJieGuoModel *tempModel = self.jiYinBiaoGeArray[row - 1];
                if (column == 4) {
                    
                } else if (column == 0) {
                    return [tempModel valueForKey:@"geneName"];
                } else if (column == 1) {
                    return [tempModel valueForKey:@"jianCeWeiDian"];
                } else if (column == 2) {
                    return [tempModel valueForKey:@"geneXing"];
                } else if (column == 3) {
                    return [tempModel valueForKey:@"gaiLue"];
                } else if (column == 5) {
                    return [tempModel valueForKey:@"influence"];
                } else if (column == 6) {
                    return [tempModel valueForKey:@"canKaoWenXian"];
                }
            }
            
        }
    } else if (formView.tag == 301) {
        if (row == 0) {
            if (column == 0) {
                return @"检测位点";
            } else if (column == 1) {
                return @"染色体图";
            }
        } else {
            if (self.jiYinBiaoGeArray.count > (row - 1)) {
                // 获得model
                JiYinJianCeJieGuoModel *tempModel = self.jiYinBiaoGeArray[row - 1];
                if (column == 0) {
                    return [tempModel valueForKey:@"jianCeWeiDian"];
                }
            }
            
        }
    }
    
    return nil;
}

- (CGFloat)formView:(KWFormView *)formView heightForRow:(NSInteger)row
{
    if (formView.tag == 300) {
        if (row == 0) {
            return 22 * kAdjustParamater;
        } else {
            return 38 * kAdjustParamater;
        }
    } else if (formView.tag == 301) {
        if (row == 0) {
            return 22 * kAdjustParamater;
        } else {
            return 38 * kAdjustParamater;
        }
    }
   
    return 0;
}

- (UIColor *)formView:(KWFormView *)formView colorOfColumn:(NSInteger)column inRow:(NSInteger)row
{
    if (formView.tag == 300) {
        return [UIColor whiteColor];
    } else if (formView.tag == 301) {
        return [UIColor whiteColor];
    }
    return nil;
}

- (UIColor *)formView:(KWFormView *)formView contentColorOfColumn:(NSInteger)column inRow:(NSInteger)row
{
    if (formView.tag == 300) {
        return [UIColor blackColor];
    } else if (formView.tag == 301) {
        return [UIColor blackColor];
    }
    return nil;
}

- (UIColor *)formViewBorderColor:(KWFormView *)formView
{
    if (formView.tag == 300) {
        return kCyanColor;
    } else if (formView.tag == 301) {
        return kCyanColor;
    }
    return nil;
}

- (UIFont *)formViewFontOfContent:(KWFormView *)formView
{
    if (formView.tag == 300) {
         return [UIFont systemFontOfSize:k11Big];
    } else if (formView.tag == 301) {
        return [UIFont systemFontOfSize:k12Big];
    }
    return nil;
}

#pragma mark - 柱状图代理
- (NSInteger)barChartView:(MCBarChartView *)barChartView numberOfBarsInSection:(NSInteger)section
{
    if (barChartView.tag == 400) {
        return 1;
    }
    return 1;
}

- (id)barChartView:(MCBarChartView *)barChartView valueOfBarInSection:(NSInteger)section index:(NSInteger)index
{
    if (barChartView.tag == 400) {
        return self.huanBingGaiLv[section];
    } else if (barChartView.tag == 401) {
        return self.jiuZhengZhiArray[section];
    }
    return nil;
}

- (NSInteger)numberOfSectionsInBarChartView:(MCBarChartView *)barChartView
{
    if (barChartView.tag == 400) {
        return 2;
    } else if (barChartView.tag == 401) {
        return 2;
    }
    return 0;
}

- (NSString *)barChartView:(MCBarChartView *)barChartView titleOfBarInSection:(NSInteger)section
{
    if (barChartView.tag == 400) {
        if (section == 0) {
            return @"中国人群患病\n概率";
        } else if (section ==1) {
            return @"您的患病\n概率";
        }
    } else if (barChartView.tag == 401) {
        if (section == 0) {
            return @"中国人群患病\n概率";
        } else if (section == 1) {
            return @"矫正后您的患病概率";
        }
    }
   
    return @"";
}

- (CGFloat)barWidthInBarChartView:(MCBarChartView *)barChartView
{
    if (barChartView.tag == 400) {
        return 35 * kAdjustParamater;
    } else if (barChartView.tag == 401) {
        return 40 * kAdjustParamater;
    }
    return 0;
}

- (CGFloat)paddingForSectionInBarChartView:(MCBarChartView *)barChartView
{
    if (barChartView.tag == 400) {
        return 30 * kAdjustParamater;
    } else if (barChartView.tag == 401) {
        return 40 * kAdjustParamater;
    }
    return 0;
}

- (UIColor *)barChartView:(MCBarChartView *)barChartView colorOfBarInSection:(NSInteger)section index:(NSInteger)index
{
    if (barChartView.tag == 400) {
        if (section == 0) {
            return [UIColor colorWithRed:78 / 255.0 green:172 / 255.0 blue:46 / 255.0 alpha:1];
        } else if (section == 1) {
            return [UIColor colorWithRed:239 / 255.0 green:159 / 255.0 blue:23 / 255.0 alpha:1];
        }
    } else if (barChartView.tag == 401) {
        if (section == 0) {
            return [UIColor colorWithRed:184 / 255.0 green:186 / 255.0 blue:21 / 255.0 alpha:1];
        } else if (section == 1) {
            return [UIColor colorWithRed:102 / 255.0 green:181 / 255.0 blue:77 / 255.0 alpha:1];
        }
    }
    return nil;
}

- (NSString *)barChartView:(MCBarChartView *)barChartView informationOfBarInSection:(NSInteger)section index:(NSInteger)index
{
    if (barChartView.tag == 400) {
        NSString *baiFenHao = @"%";
        return [NSString stringWithFormat:@"%@%@", self.huanBingGaiLv[section], baiFenHao];
    } else if (barChartView.tag == 401) {
        NSString *baiFenHao = @"%";
        return [NSString stringWithFormat:@"%@%@", self.jiuZhengZhiArray[section], baiFenHao];
    }
    return nil;
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

#pragma mark - 饼状图代理
- (NSUInteger)numberOfSlicesInPieChart:(XYPieChart *)pieChart
{
    return 2;
}

- (CGFloat)pieChart:(XYPieChart *)pieChart valueForSliceAtIndex:(NSUInteger)index
{
    if (index == 0) {
        return 98;
    }
    return 2;
}

- (UIColor *)pieChart:(XYPieChart *)pieChart colorForSliceAtIndex:(NSUInteger)index
{
    if (index == 0) {
        return [UIColor colorWithRed:122 / 255.0 green:7 / 255.0 blue:84 / 255.0 alpha:1];
    }
    return [UIColor colorWithRed:111 / 255.0 green:113 / 255.0 blue:179 / 255.0 alpha:1];
}


#pragma mark  - 表格详解
- (void)biaoGeXiangJie:(UIButton *)button
{
    NSLog(@"表格详解");
    ZGWBiaoGeXiangJieViewController *zgwBiaoGeXiangJieVC = [[ZGWBiaoGeXiangJieViewController alloc] init];
    [self.navigationController pushViewController:zgwBiaoGeXiangJieVC animated:YES];
}

- (void)canKaoWenXian:(UIButton *)button
{
    NSLog(@"参考文献");
    WenXianCanKaoListViewController *wenXianCanKaoListVC = [[WenXianCanKaoListViewController alloc] init];
    [self.navigationController pushViewController:wenXianCanKaoListVC animated:YES];
}

#pragma mark - 纠正风险值
- (void)jiuZhengFengXianButton:(UIButton *)button
{
    NSLog(@"纠正风险值");
    ZGWJiBingFengXianJiuZhengViewController *zgwJiBingFengXianJiuZhengVC = [[ZGWJiBingFengXianJiuZhengViewController alloc] init];
    __block DanXiangDieaseViewController *mySelf = self;
    zgwJiBingFengXianJiuZhengVC.ZgwJiBingFengXianJiuZheng = ^void(float jiuZhengCount) {
        // 重新布局
      //  [mySelf addMySubview];
        float jiuZhengQian = [[self.jiuZhengZhiArray firstObject] floatValue];
        NSString *jiuZhengHou = [NSString stringWithFormat:@"%.0f", jiuZhengCount * jiuZhengQian];
        [mySelf.jiuZhengZhiArray replaceObjectAtIndex:1 withObject:jiuZhengHou];
        [mySelf addJiuZhengFengXianZhuZhuangView];
    };
    [self.navigationController pushViewController:zgwJiBingFengXianJiuZhengVC animated:YES];
}

#pragma mark - 进行纠正风险值柱状图的布局
- (void)addJiuZhengFengXianZhuZhuangView
{
    // 纠正风险值柱状图
    self.jiuZhengFengXianZhiView = [[MCBarChartView alloc] initWithFrame:CGRectMake(-10 * kAdjustParamater, self.jiuZhengFengXianJieShaoBottom + 5 * kAdjustParamater, 250 * kAdjustParamater, 200 * kAdjustParamater)];
      self.jiuZhengFengXianZhiView.backgroundColor = [[UIColor whiteColor] colorWithAlphaComponent:1];
    self.jiuZhengFengXianZhiView.dataSource = self;
    self.jiuZhengFengXianZhiView.delegate = self;
    self.jiuZhengFengXianZhiView.tag = 401;
    self.jiuZhengFengXianZhiView.maxValue = @"20";
    [self.backGroundScrollview addSubview:_jiuZhengFengXianZhiView];

}





/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
